﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TBFramework;
using System.Threading.Tasks;
public class PromptInformationComponent : UIParentClass
{
    public Text text;
    bool isOver = false;
    public async Task Init(string content, float duration, bool isParentHidden,float waitTime)

    {
        isOver = false;
        if (isParentHidden)
        {
            gameObject.SetActive(true);
        }
        else
        {
            text.gameObject.SetActive(true);
        }
        Task task = StandrdUIMethod.TypeTextWithRichText(text, content, duration);
        while (!task.IsCompleted)
        {
            await Task.Yield();
        }
        await Task.Delay((int)(waitTime * 1000));
        if (isParentHidden)
        {
            gameObject.SetActive(false);
        }
        else
        {
            text.gameObject.SetActive(false);
        }        
        isOver = true;
    }
    public bool ReturnIsOver()
    {
        return isOver;
    }
}
